﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class PartOfStandartVariableExpressionElement : VariableExpressionElement
    {
        private TokenInfo token;
        private List<BlockOfPartOfStandartVariableExpressionElement> blocks;

        public TokenInfo Token { get { return token; } set { token = value; } }
        public List<BlockOfPartOfStandartVariableExpressionElement> Blocks { get { return blocks; } set { blocks = value; } }

        public PartOfStandartVariableExpressionElement(TokenInfo StartInfo, TokenInfo Token, List<BlockOfPartOfStandartVariableExpressionElement> Blocks, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            token = Token;
            blocks = Blocks;
        }

        public override string ToString()
        {
            string result = token.Text;
            if (blocks != null) result += blocks.Join();
            return result;
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (blocks != null)
                foreach (BlockOfPartOfStandartVariableExpressionElement block in blocks)
                    yield return block;
        }
    }
}
